var status = 0;
var items = Array(1302020, 1302030, 1302064, 1302081, 1312032, 1312037, 1322054, 1322060, 1332025, 1332055, 1332056, 1372034, 1382009, 1382012, 1382039, 1402039, 1402046, 1412011, 1412027, 1412033, 1422014, 1422029, 1422037, 1432012, 1432040, 1442024, 1442051, 1452016, 1452022, 1452045, 1462014, 1462019, 1462040, 1472030, 1472032, 1472055, 1482020, 1482021, 1482022, 1482023, 1492020, 1492021, 1492022);
var prize = Array(1, 2, 3, 10, 3, 10, 3, 10, 2, 3, 3, 3, 1, 2, 3, 3, 10, 2, 3, 10, 2, 3, 10, 2, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 10, 1, 2, 3);

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("*sparkle*");
   			cm.dispose();
   			return;
  		}
		if (mode == 1)
   			status++;
  		else
   			status--;
  		if (status == 0) {
   			cm.sendYesNo("Hello there\r\nI am gold, but my colors are fading\r\n#rdo you have any golden boxes for me?#k\r\n\r\n#eI really want to be gold again#n");
  		} else if (status == 1) {
   			cm.sendNext("Wonderful!\r\n#eLevel 35 weapons#n are #r1#k golden box\r\n#eLevel 43 weapons#n are #r2#k golden boxex\r\n#eLevel 64 weapons#n are #r3#k golden boxes\r\n#eLevel 120 weapons#n are #r10#k golden boxes");
  		} else if (status == 2) {
			var text = "What item do you want?\r\n";
			for (var i = 0; i < items.length; i++) {
				text += "#b#L" + i + "##v" + items[i] + "# - #r" + prize[i] + "#b golden box(es)#l#k\r\n";
			}
   			cm.sendSimple(text);
		} else {
			if (cm.canHold(items[selection])) {
				if (cm.itemQuantity(4280000) > prize[selection]) {
					cm.gainItem(items[selection], 1);
					cm.gainItem(4280000, -(prize[selection]));
					cm.dispose();
				} else {
					cm.sendOk("You do not have enough golden boxes");
					cm.dispose();
				}
			} else {
				cm.sendOk("You dont have room for this item");
				cm.dispose();
			}
		}
	}
}